import { ProColumns, ProTable } from '@ant-design/pro-components';
import '@umijs/max';
import { Modal } from 'antd';
import React from 'react';

export type CreateFormProps = {
  columns: ProColumns<API.InterfaceInfo>[];
  onCancel: () => void;
  onSubmit: (values: API.InterfaceInfo) => Promise<boolean>;
  open: boolean;
};
const CreateForm: React.FC<CreateFormProps> = (props) => {
  const { open, columns, onCancel, onSubmit } = props;
  return (
    <Modal
      open={open}
      onCancel={() => {
        onCancel?.();
      }}
      footer={null}
    >
      <ProTable
        type="form"
        columns={columns}
        onSubmit={async (value) => {
          await onSubmit(value);
        }}
      ></ProTable>
    </Modal>
  );
};
export default CreateForm;
